#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int pivotIndex(int* nums, int numsSize) {
    int total = 0, sum = 0;
    for (int i = 0; i < numsSize; i++)
    {
        total += nums[i];
    }

    for (int i = 0; i < numsSize; i++)
    {
        if (sum == total - sum - nums[i])
            return i;
        else
            sum += nums[i];
    }
    return -1;
}


int main()
{
    int nums[6] = { 1,7,3,6,5,6 };
    int ret = pivotIndex(nums, 6);
    printf("%d", ret);
	return 0;
}